package com.example.administrator.myapplication.util;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Administrator on 2020/12/7.
 */

public class MyHeloper extends SQLiteOpenHelper{

    public MyHeloper(Context context) {
        super(context, "chenziyang", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("create table caccount(id integer primary key autoincrement,"+
                "username varchar(20)not null,student_id varchar(20)not null)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
    public void insert(Context context, String username,String student_id){
        MyHeloper myHeloper=new MyHeloper(context);
        SQLiteDatabase db=myHeloper.getWritableDatabase();
        ContentValues values=new ContentValues();
        values.put("username",username);
        values.put("student_id",student_id);
        long id=db.insert("account",null,values);
        db.close();

    }
}
